<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class CourseRecord extends Model
{
    use HasFactory;

    protected $fillable = ['user_id','course_id','video_id','progress','last_position','completed_at'];
    const POSTONLY = ['user_id','course_id','video_id','progress','last_position','completed_at'];
    protected function serializeDate(\DateTimeInterface $date)
    {
        return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
    }

    public function course()
    {
        return $this->hasOne(Course::class,'id','course_id')->select('id','title','cover','type_id','price','original_price','sort','clicks','status','shop_type','tag');
    }

}
